import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart';
import 'package:exams_app/net/Address.dart';
import 'package:exams_app/net/persisten_storage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:exams_app/net/DioManager.dart';

class FackBackPage extends StatefulWidget {
  const FackBackPage({Key key}) : super(key: key);

  @override
  _FackBackPageState createState() => _FackBackPageState();
}

class _FackBackPageState extends State<FackBackPage> {

  var tf1 = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text('意见反馈'),
      ),
      body: Column(
        children: [
          Container(
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(8.0),
               ),
            margin: EdgeInsets.all(15),
            height: 100,
            child: TextField(
              controller: tf1,
              decoration: InputDecoration(
                border: InputBorder.none
              ),
              maxLength: 160,
              maxLines: 5,
            ),
          ),

          RaisedButton(

            color: Theme.of(context).primaryColor,
            onPressed: (){

              if(tf1.text.isEmpty){
                BotToast.showText(text: '请输入要反馈的内容');
                return;
              }
              requestDataSubmit();
              BotToast.showText(text: '感谢您的反馈');
              Get.back();

          },child: Text('提交',style: TextStyle(color: Colors.white),),),
        ],
      ),
    );
  }

  requestDataSubmit()async{

    // String result = await DioUtils(url: await PersistentStorage().getStorage('urlStr')).
    // postModel(Address.feedback,function_name:'',model:'',params:{'message':tf1.text});

    // String result = await DioUtils(url: await PersistentStorage().getStorage('urlStr')).post(Address.feedback,data:{'message':tf1.text});

    Dio().post('${await PersistentStorage().getStorage('urlStr')}${Address.feedback}',queryParameters:{'message':tf1.text});

  }

}
